﻿using CloudMusic.Helper;
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace CloudMusic.UC
{
    /// <summary>
    /// UCPlayList.xaml 的交互逻辑
    /// </summary>
    public partial class UCPlayListPanel : UserControl
    {
        public UCPlayListPanel()
        {
            InitializeComponent();
            //this.MouseLeftButtonDown += UC_Deactivate;
        }
        /// <summary>
        /// 
        /// </summary>
        public event RoutedEventHandler LostFocusHide;
        private void NowPlayListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            CommonHelper.RunScorllView(sender, e);
        }

        private void sourceLink_Click(object sender, RoutedEventArgs e)
        {

            var t = this.NowPlayListView.SelectedValue;
        }

        private void playPanel_LostFocus(object sender, RoutedEventArgs e)
        {
            var focused_element = FocusManager.GetFocusedElement(Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive));
            var parent = (focused_element as FrameworkElement).TryFindParent<UCPlayListPanel>();
            if (parent == null) LostFocusHide?.Invoke(this, e);
        }
    }

}
